package jp.co.sharp.android.decome.aobject;

import java.util.ArrayList;
import java.util.Random;

public class Rotation2 extends AHandler {
	private float mTheta = 0;

	ArrayList<AObject> list = new ArrayList<AObject>();

	public Rotation2() {
		for (int i = 0; i < 6; i++) {
			AObject obj = new AObject();
			obj.setXYZ(i * 150, i * 50, 0);
			list.add(obj);
		}
	}

	@Override
	public ArrayList<AObject> next(int mWidth, int mHeight) {
		// ArrayList<AObject> list = new ArrayList<AObject>();

		for (AObject obj : list) {
			float x = obj.getX();
			float y = obj.getY();
			float z = obj.getZ();
			y++;
			if (y > mHeight / 2) {
				// list.remove(obj);
				obj.setXYZ((float) new Random().nextInt(mWidth),
						(float) (int) (-mHeight / 2),
						(float) new Random().nextInt(360) / 360);
			} else {
				obj.setXYZ(x, y, z);
			}
			String bmp = null;
			switch ((((int) y + mHeight / 2) / 5) % 3) {
			case 0:
				bmp = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAjCAYAAACOysqWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAmdJREFUeNq0VkFu00AUnbE9WZsTENaU1tCiqMAiSKwQUnMD3BOAT4B6AsQJEk5AWMKmRqKqUGnjCNRtzQ287oxneDO2Jw4KNA72SE9ORuP3/n///0kIabj49HHQ5LyzAXm/MwEsHwi6FNDkt5u84DWi9+ROtxkwOQIC/nngty7A470h6UkfAoS4cth+Bp58acgLHKz7Gl0r+rOgTyS5MscVNiSeVN1i+7OsnQw8+Yb2dOQ5sVm46nUrGYgfW9rvY3tSRw+onGbI5g7bm2cbZyAu7/qI9EPN+wKeJNRDwR0y3tgiQ+6oYxD6qwQgTKijRvx8J2xskfi5VZEHFRm+o8A4ngMCcfECSj8lvc8eJslaGfCL7RG8vQJhYEg1ubccudmvQ5IZP3kQ/jUDDJFPPKWnVPf6kLKyY3p/2KKjN5G7xfO6lsU19gSdEuFG7Nm31ArwTwNN/EoTV2RGoJcviJmOVBYW1exZkNdECyTAR/BPbQ34111kgbtG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break;
			case 2:
				bmp = "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAjCAYAAACzWKvwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAK9JREFUeNpiYgCC3xusDRiggAlKC6ALMBAUcCBdC8hqB7wq5NEFFKAYRYsCugp+hAAjWADsQZY/N7QUGL58Yfj/h8kAooLtnwGD+HcGRpkvAn+eqSqw/L/HF8/A9peBgfUfAyPbvwAWhi+sB4G8AJDy/0z/F4AMPQC16QKr37EPTKwBRy9ABT4gu+MBEB9EF8AIjwfIAhfQBT4SFaYo1n6AuQfZUFLjhXQBuC0AAQYAb24tyGcveD0AAAAASUVORK5CYII=";
				break;
			}
			obj.setBmp(getBmp(bmp));
			// list.add(obj);
		}

		mTheta += 1;
		mTheta %= 360;

		return list;
	}

	@Override
	public int nextTime() {
		return 10;
	}
}
